﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace viBook.Models
{

    public class Book
    {
        public Book()
        {
            Chapters = new List<Chapter>();
        }

        public int Id { set; get; }

        [Required(ErrorMessage = "Title is required.")]
        [MaxLength(120, ErrorMessage = "Title cannot be longer than 120 characters.")]
        public string Title { set; get; }

        public int AuthorId { set; get; }

        [MaxLength(500, ErrorMessage = "Description cannot be longer than 500 characters.")]
        public string Description { set; get; }

        public string CoverUrl { set; get; }

        public DateTime UploadedDate { set; get; }
        public int UploadedBy { set; get; }
        [NotMapped]
        [MaxLength(120, ErrorMessage = "Description cannot be longer than 120 characters.")]
        public string Tag { set; get; }

        public int CategoryId { set; get; }

        [NotMapped]
        [Required(ErrorMessage = "Author is required.")]
        [MaxLength(120, ErrorMessage = "Author cannot be longer than 120 characters.")]
        public string AuthorName { set; get; }


        public int NumberOfViews { get; set; }

        public bool IsBlocked { get; set; }
        [NotMapped]
        public bool IsReported { get; set; }

        #region Computed properties

        [NotMapped]
        public virtual int NumberOfChapters { get; set; }

        [NotMapped]
        public virtual IEnumerable<BookComment> Comments { get; set; }

        [NotMapped]
        public virtual IEnumerable<ContentTag> ContentTags { get; set; }

        [NotMapped]
        public virtual IEnumerable<Chapter> Chapters { get; set; }

        [NotMapped]
        public string UploaderName { set; get; }

        [NotMapped]
        public string UploaderAvartar { set; get; }

        [NotMapped]
        public bool IsLiked { get; set; }

        [NotMapped]
        public string ListSortedChapterId { set; get; }

        [NotMapped]
        public virtual User Uploader { set; get; }

        [NotMapped]
        public string CategoryName { get; set; }

        [NotMapped]
        public int NumberOfComments { get; set; }

        [NotMapped]
        public int NumberOfLikes { get; set; }

        [NotMapped]
        public int NumberOfPage { set; get; }

        #endregion
    }
}